<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .btn-bgcolor {
            border: none;
            background-color: rgb(14, 230, 190);
        }

        .btn {
            padding: 10px 10px;
        }

        .active {
            color: white;
        }
    </style>
</head>

<body>
    <div id="app">
        <button class="btn" :class="getClass()" @click="change">我是一个按钮</button>
    </div>
    <!-- <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> -->
    <script src="../assets/vue3.js"></script>
    <script>
        const app = Vue.createApp({
            data() {
                return {
                    isActive: false
                }
            },
            methods: {
                getClass() {
                    return { 'btn-bgcolor': true, 'active': this.isActive }
                },
                change() {
                    this.isActive = !this.isActive;
                }
            },
        });
        app.mount('#app');
    </script>
</body>

</html>